package edu.scu.declaresys.service.impl;

import java.util.List;

import edu.scu.declaresys.dao.DAOFactory;
import edu.scu.declaresys.dao.intr.INewsClassDAO;
import edu.scu.declaresys.dao.util.Depth;
import edu.scu.declaresys.exception.ExecuteException;
import edu.scu.declaresys.service.intr.INewsClassService;
import edu.scu.declaresys.vo.NewsClass;

public class NewsClassServiceImpl implements INewsClassService
{
	private INewsClassDAO newsClassDao = DAOFactory.createNewsClassDAO();
	
	
	@Override
	public void deleteClass(Integer classId) throws ExecuteException
	{
		newsClassDao.delete(classId);
	}
	
	@Override
	public Integer addClass(NewsClass vo) throws ExecuteException
	{
		return newsClassDao.save(vo);
	}

	@Override
	public void modifyClass(NewsClass vo) throws ExecuteException
	{
		newsClassDao.update(vo, vo.getId());
	}
	
	@Override
	public List<NewsClass> findClassList() throws ExecuteException
	{
		return newsClassDao.findByProperty(null, null, Depth.ZERO, null, null, null, null);
	}
	
	@Override
	public NewsClass findClass(Integer classId) throws ExecuteException
	{
		return newsClassDao.findById(classId, Depth.ZERO);
	}
	
	@Override
	public NewsClass findClassByName(String className) throws ExecuteException
	{
		return newsClassDao.findByPropertyUnique(NewsClass.T_NAME, className, Depth.ZERO);
	}
}
